﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace ArkanoidX.UI
{
    class MessageDialog : Window
    {
        Text message;

        public MessageDialog(MainGame game, Window parent)
            : this(game, parent, "Sorry, not yet available")
        {
            canBeActivated = true;
            canBeFocused = true;
        }

        public MessageDialog(MainGame game, Window parent, String text)
            : base(game, parent)
        {
            int width = game.GameRectangle.Width * 2/5;
            int height = game.GameRectangle.Height * 2/5;
            
            Vector2 size = new Vector2(width, height);
            this.Align(game.GameRectangle, AlignType.Center, size, 0, 0);

            message = new Text(game);
            message.Value = text;
            message.Scale = new Vector2(1f, 1f);
            message.Align(this.boundingRect, AlignType.Center, 0, 0);

            this.AddChild(message);
        }

        public override void TryHandleKeyEvent(GameTime gameTime, Window.KeyStrokeEvent e)
        {
            if (e.key == Keys.Enter)
            {
                this.Close();
                this.modalResult = ModalResult.OK;
            }
            else if (e.key == Keys.Escape)
            {
                this.Close();
                this.modalResult = ModalResult.Cancel;
            }
            e.consumed = true;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }
    }
}
